home *** CD-ROM | disk | FTP | other *** search
/ Web Shop Designer 2000 / Web Shop Designer 2000 - Disc 1.iso / Web Examples / Registrations / WebSite / CGI-BIN / CGI4.cgi < prev   
Text File  |  1998-08-27  |  15KB  |  467 lines

  1. $cginame = "CGI4";
  2. $cgifolder = "";
  3. $pageURL = "../SoftwareFrameSource.htm";
  4. $cgiurl = "\""."$cgifolder"."$cginame".".cgi"."\"";
  5. $template = "Template1";
  6. ###############################################################
  7. #             1.Environmental prefix                          #
  8. ###############################################################
  9. #                  *-OS platform -*                           #
  10. $osplat = "Win32";
  11. #             *-DB connectivity platform-*                    #
  12. $dbplat = "ODBC";
  13. ###############################################################
  14. #             2.Section of datasource properies               #
  15. ###############################################################
  16. $dbname = "Registration";
  17. ###############################################################
  18. #              3.Section of columns                           #
  19. ###############################################################
  20. $command = SELECT;
  21. @columns = ( 'FirstName','LastName','CompanyName','Telephone','Email','Address');
  22. @captions = ( 'First Name','Last Name','Company Name','Phone','E-Mail','Address');
  23. @columntype = ( 'NONE','NONE','NONE','NONE','MAIL','NONE');
  24. ###############################################################
  25. #              4.Section of controls                          #
  26. ###############################################################
  27. @controls = ();
  28. @controlvalues = ();
  29. &get_control_values(@controls);
  30. ###############################################################
  31. #        5.Section of script body where    generated SQL      #
  32. #       statement template is to be placed with appropriate   #
  33. #                        insertions                           #
  34. ###############################################################
  35. $stmt0 = "SELECT reginfo.FirstName,reginfo.LastName,reginfo.CompanyName,reginfo.Telephone,reginfo.Email,reginfo.Address\n
  36.  FROM reginfo\n
  37. ORDER BY  LastName ASC";
  38.    ###############################################################
  39.    #              6.Section of feedback properies                #
  40.    ###############################################################
  41. @colors = ("d3d3d3","ffffff");
  42. $quota = 3;
  43. $style = 1;#0-List,1-Table
  44. $border = 1;
  45. $link = 0;#0-Link,1-Embed
  46. $head1 = "Registration List";  #first line
  47. $head2 = "";  #second line
  48. $align = "center";
  49. ##################### End of prefix ###########################
  50.  
  51. #$test = FALSE;
  52. #####################Standard remainder of the script##########
  53. $useplatstr = "use "."$osplat"."::"."$dbplat";
  54. eval $useplatstr;
  55. use CGI ':standard';
  56. $header = "Header";
  57.  
  58. #################################################################
  59. #        7.Section of script body responsible                   #
  60. #             for input from stdio                              #
  61. #        and output to stdio footer's lines                     #
  62. #################################################################
  63. print header;
  64. #print   "<center><U><B><FONT SIZE=\"+5\">SQL TEST</FONT></B></U><center>";
  65. if (param()) {
  66.  }
  67.  
  68. #################################################################
  69. #        8.Section of script body responsible                   #
  70. #           for placing controls' values                        #
  71. #      in appropriate places in "controlvalues" array           #
  72. #      and placing received cursor in $cursor variable          #
  73. #################################################################
  74. $cursor = param('Cursor');
  75.  
  76. #################################################################
  77. #        9.Section of script body responsible                   #
  78. #           for placing controls' values                        #
  79. #      in appropriate places in "controlvalues" array           #
  80. #      and placing received cursor in $cursor variable          #
  81. #################################################################
  82. if($test){
  83. print '<FORM ACTION=';
  84. print $cgiurl;
  85. print 'METHOD=POST>';
  86. $colindex = 0;
  87. foreach $control (@controls){
  88.  print '<CENTER>';
  89.  $temp = $controls[$colindex];
  90.  print $temp ;
  91.  print '</CENTER><BR>';    
  92.  print '<CENTER>';
  93.  print '<INPUT TYPE="text" NAME="';
  94.  print $control;
  95.  print '"';
  96.  print ' VALUE="';
  97.  $temp = $controlvalues[$colindex];
  98.  print $temp;
  99.  print '" >';
  100.  print '</CENTER>';    
  101.  print '<BR >';
  102.  $colindex = $colindex + 1;
  103. }
  104. if($colindex){
  105. print '<BR><BR>';
  106. print '<CENTER>';
  107. print '<INPUT TYPE="Submit" NAME="submit"';
  108. print '</CENTER>';
  109. print '</FORM>';
  110. }
  111. }
  112.  
  113. #################################################################
  114. #        10.Section of script body where    generated SQL        #
  115. #statement template is to be placed with appropriate insertions #
  116. #     and   responsible  for getting  final sight  of SQL       #
  117. ################################################################# 
  118. $stmtval = "\$stmt"."= \""."$stmt0"."\"";
  119. eval  $stmtval;
  120.  
  121. #################################################################
  122. #             11.Section of script body                          #
  123. #     responsible  for making connection to DBASE and           #
  124. #         getting count of rows                                 #
  125. ################################################################# 
  126. $plat = "\$db"." = "."new "."$osplat"."::"."$dbplat"."("."$dbname".")";
  127. eval $plat;
  128. if (!$db){
  129.  &print_db_error;
  130.  return;
  131. }
  132. $lor = $db->Sql($stmt);
  133. if ($lor){
  134.  &print_sql_error;
  135.  return;
  136. }
  137. $rowtotal = &get_total_rows;
  138.  
  139. #################################################################
  140. #             12.Section of script body                         #
  141. #        responsible  for output "Query results" line           #
  142. #             along with total count of rows                    #
  143. #################################################################
  144. #### only for debugging purpose
  145. if($test){
  146. print $stmtval,p;
  147. }
  148. print   "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR VALIGN=\"top\" ALIGN=\"center\" bgcolor=\"#aaaacc\">";
  149. print   "<TD COLSPAN=2><H1> $head1</H1></TD></TR>";
  150. print   "<TR VALIGN=\"top\" ALIGN=\"center\" bgcolor=\"#aaaacc\">";
  151. print   "<TD COLSPAN=2><H1>$head2</H1></TD></TR>";
  152. print   "</TABLE>";
  153. print   "<center><U><B>QUERY RESULTS - $rowtotal matches</B></U><center>";
  154. print   "<BR><BR>";
  155.  
  156. #################################################################
  157. #             13.Section of script body                         #
  158. #        responsible  for calculation range of                  #
  159. #              query portion for feedback page                  #
  160. #################################################################
  161. $start = $cursor;
  162. $end = $cursor + $quota;
  163. if($end >= $rowtotal){
  164. $end = $rowtotal;
  165. $cursornext = 0;
  166. }
  167. else
  168. {
  169.  $cursornext = $cursor + $quota;
  170. $cursorprev = $cursor - $quota;
  171.  
  172. #################################################################
  173. #             14.Section of script body                         #
  174. #        responsible  for calculation range of                  #
  175. #                   query portion                               #
  176. #           output them in outgoing stream                      #
  177. #################################################################
  178. &print_range_line($rowtotal,$start,$end);
  179.  
  180. #################################################################
  181. #             15.Section of script body                         #
  182. #        responsible  for output of table captions              #
  183. #            for query columns on feedback page                 #
  184. #################################################################
  185.  print   "<TABLE BORDER=$border CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR VALIGN=\"top\" ALIGN=\"$align\" bgcolor=\"#aaaacc\">";
  186.  $capindex = 0;
  187.  @fieldnames = $db->FieldNames();
  188.  foreach $caption (@captions){
  189.  if($caption eq ""){
  190.   &print_header_cell($fieldnames[$capindex]);
  191.  } else{
  192.   &print_header_cell($captions[$capindex]);
  193.  }$capindex = $capindex + 1;
  194.  }
  195.  
  196. #################################################################
  197. #             16.Section of script body                         #
  198. #        responsible  for fetching rows from DBASE              #
  199. #